package com.model.proxy
{
	import mx.rpc.IResponder;
	import mx.rpc.remoting.mxml.RemoteObject;

	public class RemoteDelegate
	{
		private var service:RemoteObject;
		private var responder:IResponder;
		public var remoteSource:String;
		public var remoteMethod:String;
		public var remoteArguments:Object;

		public function RemoteDelegate(pResponder:IResponder, pSource:String, pMethod:String, pEndpoint:String)
		{
			service=new RemoteObject();
			service.endpoint=pEndpoint;
			service.destination="zend";
			service.makeObjectsBindable=true;
			service.source=pSource;
			remoteMethod=pMethod;
			responder=pResponder;
		}

		public function sendData():void
		{
			service.getOperation(remoteMethod).arguments=remoteArguments;
			var call:Object=service.getOperation(remoteMethod).send();
			call.addResponder(responder);
			remoteArguments=[];
			call=null;
		}

		public function disconnectService():void
		{
			service.disconnect();
		}
	}
}